package com.example.safehome;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

public class WaterInAdapter extends ArrayAdapter<WaterWarningRecord> {
    private int resourceId;
    public WaterInAdapter(Context context, int textViewResourceId, List<WaterWarningRecord>bojects) {
        super(context, textViewResourceId, bojects);
        resourceId = textViewResourceId;
    }
    @Override
        public View getView(int position, View converView, ViewGroup parent) {
            WaterWarningRecord record=getItem(position);
            View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
            TextView id=(TextView)view.findViewById(R.id.tv_id);
            TextView WaterInTime=(TextView)view.findViewById(R.id.tv_Water_In_Time);
            TextView WaterInPlace=(TextView)view.findViewById(R.id.tv_Water_In_Place);
            TextView IsCallPolice=(TextView)view.findViewById(R.id.tv_Is_Call_Police);
            TextView Detail=(TextView)view.findViewById(R.id.tv_Detail);
            id.setText(Integer.toString(record.getId()));
            WaterInTime.setText(record.getWaterInTime().toString());
            WaterInPlace.setText(record.getWaterInPlace());
            if (record.getIsCallPolice())
                IsCallPolice.setText("是");
            else
                IsCallPolice.setText("否");
            Detail.setText(record.getDetail());
            return view;
        }
}
